﻿#region Header

/*
Remote views based on linq
By

Pascal Hauser 
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

and

Raphael Gfeller
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

*/

#endregion

#region Usings

using System;
using InterLinq.Base;
using Sebarf.Core.Interfaces;
using Sebarf.Utils.Interfaces;

#endregion

namespace Sebastof.ProcessChains.ProcessSteps {
	/// <summary>
	/// This is another processing step.
	/// Here we save away the original data of a transfered object so we can later check what changed.
	/// </summary>
	public class CachedOriginalDataObject : CachedOriginalDataBase<object> {
		#region Public Properties

		// public Properties located here

		#endregion

		#region Public Methods

		public CachedOriginalDataObject(IServiceLocatorService context)
			: base(context, context.GetRegisteredService<IChangeTrackingCacheService>()) {
		}

		public CachedOriginalDataObject() {
		}

		protected override Object OnProcess(Object toProcess) {
			try {
				IObjectHierarchyFlattenerService hf = ObjectHierarchyFlattenerService;
				hf.FieldInfoLookup = m_FieldInfos;
				foreach (object o in hf.Flatten(toProcess)) {
					PrepareForType(o.GetType());
					AddObjectData(o);
				}
			}
			catch {
				throw;
			}
			return base.OnProcess(toProcess);
		}

		#endregion

		#region Private Fields

		#endregion
	}
}